package org.bonorsoft.modules.system.framework.web.service;

import org.bonorsoft.common.util.oConvertUtils;
import org.bonorsoft.modules.control.entity.Label;
import org.bonorsoft.modules.control.service.ILabelService;
import org.bonorsoft.modules.system.entity.SysDictItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

@Service("label")
public class LabelService {

    @Autowired
    private ILabelService labelService;

    /**
     * 根据字符标识获取标签的值
     *
     * @param value
     * @return
     */
    public String getParamValue(String value) {

        StringBuilder names = new StringBuilder();
        if (oConvertUtils.isNotEmpty(value)){
            String[] values = value.split(",");
            for (String svalue : values) {
                Label label;
                label = labelService.getById(svalue);
                String labelName = label.getLabelName();
                names.append(labelName + " ");
            }
        }
        String name = names.toString();
        return name;
    }


    public List<Label> getType()
    {
        return labelService.list();
    }
}
